import os.path
import cherrypy

from slum.model.song import Song

WEB_DIR = 'slum/web'

class Server:
    song = Song()

if __name__ == '__main__':
    # Set up site-wide config first so we get a log if errors occur.
    cherrypy.config.update({'environment'   : 'production',
                            'log.error_file': 'server.log',
                            'log.screen'    : True})

    current_dir = os.path.dirname(os.path.abspath(__file__))
    conf = {
        'global' : {
            'server.socket_port' : 80
        },
        '/' : {
            'tools.staticdir.on'    : True,
            'tools.staticdir.dir'   : os.path.join(current_dir, WEB_DIR),
            'tools.staticdir.index' : 'index.html',
            'tools.staticdir.content_types': {
                'html': 'text/html',
                'css' : 'text/css',
                'js'  : 'text/javascript'
            }
        }
    }

    cherrypy.quickstart(Server(), '/', config=conf)
